package com.jbit.dm_160.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.jbit.dm_160.mapper.ItemMapper;
import com.jbit.dm_160.model.dto.FloorItemDTO;
import com.jbit.dm_160.model.dto.ItemDTO;
import com.jbit.dm_160.model.entity.Item;
import com.jbit.dm_160.model.vo.SearchVO;
import com.jbit.dm_160.service.ItemService;
import com.jbit.dm_160.utils.Page;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class ItemServiceImpl implements ItemService {
    @Resource
    private ItemMapper itemMapper;
    @Override
    public List<ItemDTO> getItemByType1Id(Integer type1Id) {
        return itemMapper.getItemByType1Id(type1Id);
    }

    @Override
    public List<ItemDTO> getHotItems() {
        return itemMapper.getHotItems();
    }

    @Override
    public List<ItemDTO> getItemsByState(Integer state) {
        return itemMapper.getItemsByState(state);
    }

    @Override
    public List<FloorItemDTO> getItemsByFloor(Integer type1Id) {
        return itemMapper.getItemsByFloor(type1Id);
    }

    @Override
    public Page<ItemDTO> getItemsBySearchInfo(SearchVO searchVO) {
        PageHelper.startPage(searchVO.getCurrentPage(),searchVO.getPageSize());
        List<ItemDTO> list = itemMapper.getItemsBySearchInfo(searchVO);
        return Page.clone(new PageInfo<>(list));
    }

    @Override
    public ItemDTO getItemDetailById(Integer id) {
        return itemMapper.getItemDetailById(id);
    }
}
